#include <iostream>
using namespace std;
int main()
{
    int year = 0, month = 0, day = 0, sum = 0;
    cin >> year >> month >> day;
    static int arr[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    for (int i = 1; i < month; ++i)
    {
        sum += arr[i];
    }
    // if (month > 2 && (year % 4 == 0 && year % 400 != 0))
    if (month > 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
    {
        ++sum;
    }
    cout << sum + day;
    return 0;
}